import { ref } from 'vue'

export const Nodedata = ref<any>(null)

//处理数据变化
export const handleChange = (): void => {
  const newData = stringToNumber()
  window.api.handleCanvasData('updateNodes', 'property', true, [newData])
}

//解决某些属性类型改变的问题
const stringToNumber = () => {
  const newData = JSON.parse(JSON.stringify(Nodedata.value))

  newData.x = Number(newData.x)
  newData.y = Number(newData.y)
  newData.width = Number(newData.width)
  newData.height = Number(newData.height)
  newData.rotate = Number(newData.rotate)

  return newData
}
